/****************************************/
/* Application.h			 			*/
/* Created on: Sep 4, 2011				*/
/* Copyright Playsoft 2011				*/
/* Released under GPL v2				*/
/****************************************/

#ifndef APPLICATION_H_
#define APPLICATION_H_

//----------------------------------------------------------------------

#include <allegro.h>
#include <string>
#include <sstream>
#include <iostream>
#include <stdlib.h>
#include <time.h>

#include "Player.h"
#include "Leg.h"
#include "Bottom.h"
#include "Flower.h"

//----------------------------------------------------------------------

class Application
{
	public:
		Application();
		virtual ~Application();

	private:
		enum State
		{
			SPLASH,
			INTRO,
			GAME,
			GAME_OVER
		};

	public:
		bool running;
		State currentState;

	private:
		float currentGrowSpeed;
		float currentHeight;
		float growAcceleration;
		float gravityAcceleration;
		int FPS;
		int frameCounter;

	private:
		Player* m_Player;
		Leg *legs[4];
		Bottom *bottom;

	private:
		std::string statusString;

	private:
		BITMAP *buffer;

	private:
		SAMPLE *jingle;
		SAMPLE *start;
		SAMPLE *lose;

	private:
		BITMAP *play;
		BITMAP *intro;

	private:
		BITMAP *background;

	private:
		Flower * flowers[6];

	private:
		void setState(State s);

	public:
		void run();
		void cleanup();

	public:
		void update();
		void draw();

	public:
		void updateSplash();
		void drawSplash();
		void updateIntro();
		void drawIntro();
		void updateGame();
		void drawGame();
		void updateGameOver();
		void drawGameOver();

	public:
		std::string intToString(int i);
};

//----------------------------------------------------------------------

#endif
